<template>
  <div class="page-containers">
    <!--工具栏-->
    <div class="toolbar">
      <el-table :data="cardList" >
        <el-table-column prop="id" label="ID"></el-table-column>
        <el-table-column prop="discountCardCode" label="卡号"></el-table-column>
        <el-table-column label="折扣卡名称">
          <template slot-scope="scope">
            <el-button
              type="text"
              class="textButton"
              @click="discountCardDeatail(scope.row)"
            >{{scope.row.discountThemeName}}</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="discountValue" label="折扣"></el-table-column>
        <el-table-column label="有效期">
          <template slot-scope="scope">
            <span>{{ scope.row.startTime }} -  {{ scope.row.endTime }}</span>
          </template>
        </el-table-column>
        <el-table-column prop="deptName" label="所属组织"></el-table-column>
        <el-table-column prop="createTime" label="绑定时间"></el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
  import {format} from "@/utils/datetime";
  import cardRequest from "@/discountCard/request/cardRequest";
  export default {
    components: {

    },
    data() {
      return {
        thirdUserId:this.$route.params.thirdUserId,
        deptMsg:localStorage.getItem('user'),//当前登录组织信息
        userId:localStorage.getItem("userId"),//当前登录用户id
        deptType:localStorage.getItem("deptType"),//当前登录用户所属组织类型

        cardList:[],

      };
    },
    methods: {
      discountCardDeatail: function(data) {
        this.$router.push({path:"/pages/DiscountCard/DiscountCardDetail/" + data.discountThemeId});
      },


      findMyDiscountCardList(){
        let this_ = this;
        let callback = function(res) {
          if (res.code == "0000") {
            this_.cardList = res.data;
          } else {
            this_.$message({ message: "查询折扣卡记录失败", type: "fail" });
          }
        };
        let param = { thirdUserId: this.thirdUserId };
        cardRequest.discountCardHistory(param, callback);
      },
    },

    mounted() {
        this.findMyDiscountCardList();
    }
  };
</script>

<style lang="scss" scoped>
  .reset {
    background-color: #fff;
    color: #409eff;
  }
  .noMargin{
    margin-right: 0 !important;
    margin-bottom: 0 !important;
  }
</style>
